/*
Package service
@Time : 2022/12/21 15:33
@Author : 董胜烨
@File : admin
@Software: GoLand
@note:
*/
package service

import (
	"employee/model"
	"fmt"
)

type Admin struct {
	Name     string `json:"name"`
	Account  string `json:"account"`
	Password string `json:"password"`
}

func (a *Admin) Check() bool {
	sqlStr := fmt.Sprintf("SELECT * FROM admin WHERE account='%s'", a.Account)
	res := model.QueryAll(sqlStr)
	if res != nil {
		if res[0]["password"] == a.Password {
			a.Name = res[0]["name"]
			return true
		}
	}
	return false
}
